package com.fuxian.dao.mybatisImpl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.stereotype.Repository;

import com.fuxian.dao.NoticeDao;
import com.fuxian.model.Notice;
@Repository
public class NoticeDaoMybatisImpl implements NoticeDao {
	@Resource
	private SqlSessionTemplate sqlSessionTemplate;
	public void addNotice(Notice notice) {
		sqlSessionTemplate.insert("addNotice", notice);

	}

	public void deleteNoticeById(int id) {
		sqlSessionTemplate.delete("deleteNoticeById", id);

	}

	public void modifyNotice(Notice notice) {
		sqlSessionTemplate.update("modifyNotice", notice);

	}

	public List<Notice> selectAllNotice(int start,int size) {
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("start", start);
		map.put("size", size);
		List<Notice>list=sqlSessionTemplate.selectList("selectAllNotice", map);
		return list;
	}

	public List<Notice> selectNoticeByAuthor(Map map) {
		List<Notice>list=sqlSessionTemplate.selectList("selectNoticeByAuthor", map);
		return list;
	}

	public List<Notice> selectNoticeByCreatetime(Map map) {
		List<Notice>list=sqlSessionTemplate.selectList("selectNoticeByCreatetime", map);
		return list;
	}

	public Notice selectNoticeById(int id) {
		Notice notice=sqlSessionTemplate.selectOne("selectNoticeById", id);
		return notice;
	}
	
	public int selectNoticeCount(){
		return sqlSessionTemplate.selectOne("selectNoticeCount");
	}

}
